

{template 'common/header'}
<style>
	#s_province,#s_city{width:50%;height:34px;padding: 6px 12px;border:1px solid #ccc;border-radius: 4px;}
</style>
<div class='container' style='padding:0 5px 10px;margin:0;width:100%'>

<ul class="nav nav-tabs">
  <li {if $op == 'post'}class="active"{/if}><a href="{php echo $this->createWebUrl('dealer_manage', array('op' => 'post'));}">添加数据</a></li>
  <li {if $op == 'display'}class="active"{/if}><a href="{php echo $this->createWebUrl('dealer_manage',array('op'=>'display'));}">管理数据</a></li>
 
</ul>
{if $op =='display'}
<div class="panel panel-success">
  <div class="panel-heading">常用工具 > 数据列表</div>
  
</div>

	<form id="form2" class="form-horizontal" method="post">
		<table class="table table-hover">
			<thead class="navbar-inner">
				<tr>
				<th style="width:40px;">全选</th>
					<th style="width:50px;">ID</th>
					<th style="width:100px;">公司</th>					
          			<th style="width:90px;">省份</th>
          			<th style="width:80px;">城市</th>
          			<th style="width:60px;">详细地址</th>
					<th style="min-width:60px;width:60px;">删除</th>
				</tr>
			</thead>
			<tbody>
				{loop $list $item}
				<td><input type="checkbox" value="{$item['id']}" name="delete[]"></td>
					<td>{$item['id']}</td>
					<td>{$item['company']}</td>
					<td>{$item['province']}</td>
					<td>{$item['city']}</td>
					<td>{$item['address']}</td>
					<td>
					<a href="{php echo $this->createWebUrl('dealer_manage', array('op' => 'post', 'id' => $item['id']))}" title="编辑" class="btn btn-xs btn-primary"><span class="icon icon-compose">编辑</span></a>
					
					<a onclick="if(confirm('此操作不可恢复，确认吗？')){location.href='{php echo $this->createWebUrl('dealer_manage', array('id' => $item['id'],'op'=>'del'))}'}" href="javascript:;" title="删除" class="btn btn-xs btn-danger"><span class="icon icon-close">删除</span></a>
					</td>				
				</tr>
				
				{/loop}
				<tr >
				<td><input type="checkbox"  onclick="var ck = this.checked;$(':checkbox').each(function(){this.checked = ck});" name=''>    <input class="btn btn-primary btn-xs" type="submit" value="删除" name="submit" ></td><td></td><td></td><td></td>
				</tr>
			</tbody>
		</table>
		<input type="hidden" value="dealer_manage" name="do">
		<input type="hidden" value="del" name="op">
		<input type="hidden" name="token" value="{$_W['token']}" />
		
	</form>
	{$pager}
	<script>
		$(function(){
			$('.pagination').removeClass().children().addClass('pagination');
		})
	</script>
	<script>
		$('#form2').submit(function(){
			if($(":checkbox[name='delete[]']:checked").size() > 0){
				return confirm('删除后不可恢复，您确定删除吗？');
			}
			return false;
		}); 
	</script>	
	</div>
{elseif $op == 'post'}
<div class="panel panel-success">
  <div class="panel-heading">常用工具 > 经销商查询 > 添加/修改数据</div>
</div>
<div class="main">
	<form action="" method="post" class="form-horizontal form">
	<div class="panel panel-default">
		<div class="panel-body">
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">公司</label>
				<div class="col-sm-8">
					<input type="text" name="company" class="form-control" value="{$item['company']}" /> 
					<span class="help-block"></span>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">所属省份</label>
				<div class="col-sm-8">
					<select id="s_province" name="province"></select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">所属城市</label>
				<div class="col-sm-8">
					<select id="s_city" name="city" ></select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">详细地址</label>
				<div class="col-sm-8">
					<input type="text" name="address" class="form-control" value="{$item['address']}" /> 
					<span class="help-block"></span>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label"></label>
				<div class="col-sm-4">
				<input type="hidden" name="id" value="{$item[id]}">
				<input type="hidden" name="token" value="{$_W['token']}" />
					<input name="submit" type="submit" value="提交" class="btn btn-primary span3" />
				</div>
			</div>
			</div>
			</div>
	</form>
</div>
	
{/if}		
</div>
<script src="<?php echo MODULE_URL;?>/template/mobile/js/area.js"></script>
<script type="text/javascript">_init_area();</script>
<script type="text/javascript">
		function Gid($){
			return document.getElementById($);
		}
		var showArea = function(){
			Gid('show').innerHTML = "<h3>省" + Gid('s_province').value + " - 市" + 	
			Gid('s_city').value + " - 县/区" + 
			Gid('s_county').value + "</h3>"
		}
	</script>
<script>
require(['jquery','util'], function($, util){
	$(function(){
		var editor = util.editor($('#remark')[0]);
 
	});
});
</script>
{template 'common/footer'}
